const { cloud } = getApp();
Page({
  data: {
    imageList: [

      {
        "id": 1,
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN015Jp8Ea1Ous2Kq8uuh_!!376771766.png"
      },
      {
        "id": 2,
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01YEAtGT1Ous2RSnPRG_!!376771766.png"
      },
      {
        "id": 3,
        "url": "https://img.alicdn.com/imgextra/i2/376771766/O1CN01ttqx6P1Ous2LmsckH_!!376771766.png"
      },
      {
        "id": 4,
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01pF6jKG1Ous2S796oW_!!376771766.png"
      },
      {
        "id": 5,
        "url": "https://img.alicdn.com/imgextra/i1/376771766/O1CN01Hvl81b1Ous2PvTUO8_!!376771766.png"
      },
      {
        "id": 6,
        "url": "https://img.alicdn.com/imgextra/i4/376771766/O1CN01M8nGlC1Ous2QuzXD6_!!376771766.png"
      }
    ],
  },
  onLoad(e) {

  },
  async choose(e) {
    let id = e.currentTarget.dataset.id;
    console.log(id)
    let info = this.data.imageList.find(item => item.id == id);
    let sendData = { shop_id: getApp().globalData.shop_id, topImage: info.url };
    const res = await cloud.application.httpRequest({
      path: '/index.php/index/qn/writeset',
      method: 'POST',
      params: sendData
    })
    my.alert({
      title: '设置成功，返回之后再次刷新页面可以看到设置效果',
      success: (res) => {
        my.navigateTo({
          url: '/pages/index/index'
        });
      }
    });

  }

});
